package com.hyzx.qbasic.admin.domain.repository.impl;

import com.hyzx.qbasic.admin.model.po.CommonAttachmentPO;
import com.hyzx.qbasic.admin.model.po.CommonImagePO;
import com.hyzx.qbasic.admin.domain.dao.CommonFileMapper;
import com.hyzx.qbasic.admin.domain.repository.ICommonFileRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by 黄江华 on 2018/8/10
 */

@Repository
public class CommonFileRepositoryImpl implements ICommonFileRepository {

    @Autowired
    private CommonFileMapper commonFileMapper;

    @Override
    public boolean saveImage(CommonImagePO image) {
        return commonFileMapper.saveImage(image) > 0;
    }

    @Override
    public boolean saveFile(CommonAttachmentPO attachment) {
        return commonFileMapper.saveFile(attachment) > 0;
    }

    @Override
    public boolean deleteAttachment(Integer fileId) {
        return commonFileMapper.deleteAttachment(fileId) > 0;
    }

    @Override
    public boolean deleteAttachmentByBusinessId(String businessId) {
        return commonFileMapper.deleteAttachmentByBusinessId(businessId)>0;
    }

    @Override
    public boolean deleteImage(Integer imageId) {
        return commonFileMapper.deleteImage(imageId)>0;
    }

    @Override
    public boolean deleteImageByBusinessId(String businessId) {
        return commonFileMapper.deleteImageByBusinessId(businessId)>0;
    }

    @Override
    public CommonAttachmentPO getAttachmentInfo(Integer fileId) {
        return commonFileMapper.getAttachmentInfo(fileId);
    }

    @Override
    public List<CommonAttachmentPO> getAttachmentList(String businessId) {
        return commonFileMapper.getAttachmentList(businessId);
    }

    @Override
    public CommonImagePO getImageInfo(Integer imageId) {
        return commonFileMapper.getImageInfo(imageId);
    }

    @Override
    public List<CommonImagePO> getImageList(String businessId) {
        return commonFileMapper.getImageList(businessId);
    }
}
